<template>
  <el-dialog
    :title="`${isEdit ? '编辑' : '新增'}调度`"
    :visible.sync="dialogVisible"
    width="30%"
    :close-on-click-modal="false"
    :before-close="close"
  >
    <div>
      <el-form
        ref="RefForm"
        :model="formData"
        label-width="120px"
        :rules="formRules"
        status-icon
      >
        <el-form-item label="调度编码" prop="name">
          <el-input v-model="formData.name"></el-input>
        </el-form-item>
        <el-form-item label="调度名称" prop="loginName">
          <el-input v-model="formData.loginName"></el-input>
        </el-form-item>
        <el-form-item label="类名" prop="password">
          <el-input v-model="formData.password"></el-input>
        </el-form-item>
        <el-form-item label="时间间隔" prop="name">
          <el-input v-model="formData.name"></el-input>
        </el-form-item>
        <el-form-item label="最后运行时间" prop="loginName">
          <el-input v-model="formData.loginName"></el-input>
        </el-form-item>
        <el-form-item label="间隔模式" prop="password">
          <el-select v-model="formData.loginName" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="状态" prop="password">
          <el-input v-model="formData.password"></el-input>
        </el-form-item>
        <el-form-item label="参数串" prop="name">
          <el-input v-model="formData.name"></el-input>
        </el-form-item>
        <el-form-item label="调度描述" prop="loginName">
          <el-input v-model="formData.loginName"></el-input>
        </el-form-item>
        <el-form-item label="备注" prop="password">
          <el-input v-model="formData.password"></el-input>
        </el-form-item>
      </el-form>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">取 消</el-button>
      <el-button
        :loading="loadingSubmit"
        type="primary"
        @click="handleSubmit"
      >确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import dialogEditMixin from '@/mixins/dialogEdit'
  import { eleValidator } from '@/utils/tools'
  export default {
    mixins: [dialogEditMixin],
    data() {
      return {
				options: [
					{ label: '秒', value: 1 },
					{ label: '分', value: 2 },
					{ label: '时', value: 3 },
					{ label: '日', value: 4 },
					{ label: '月', value: 5 },
					{ label: '年', value: 6 },
				],
        formRules: {
          name: [
            { required: true, message: '请输入姓名', trigger: 'blur' },
            {
              validator: eleValidator([
                { rule: 'isEmpty', msg: '姓名不能为空' }
              ]),
              trigger: 'blur'
            }
          ],
          loginName: [
            { required: true, message: '请输入登录名', trigger: 'blur' }
          ],
          password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
        },
        apiKey: {
          search: '/User/',
          add: '/User',
          put: '/User/'
        }
      }
    },
    methods: {
      resetFormData() {
        this.formData = {
          loginName: '',
          name: '',
          password: '',
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
	.el-select {
		width: 100%;
	}
</style>
